import 'package:duuchin/config/app_colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class SingerCard extends StatelessWidget {
  final String coverPictureUrl;
  final String nickname;
  final int musicCount;
  final int musicPlayCount;

  const SingerCard(
      {Key key,
      this.coverPictureUrl,
      this.nickname,
      this.musicCount,
      this.musicPlayCount})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        _singImg(),
        _singName(),
        Row(
          children: <Widget>[
            _singIcon('assets/images/icons/read.png', '歌曲:', musicCount),
            _singIcon('assets/images/icons/read.png', '播放:', musicPlayCount),
          ],
        )
      ],
    );
  }

  Widget _singIcon(String icon, String lable, int count) {
    return Expanded(
      child: Row(
        mainAxisAlignment:MainAxisAlignment.center,
        children: <Widget>[
          Image.asset(
            icon,
            width: 16,
            height: 16,
          ),
          SizedBox(width: 2),
          Expanded(
            child: Text(
              lable + count.toString(),
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(color: AppColors.unactive, fontSize: 12),
            ),
          ),
        ],
      ),
    );
  }

  /// 歌手姓名布局
  Widget _singName() {
    return Padding(
      padding: EdgeInsets.symmetric(vertical: 10),
      child: Text(
        nickname,
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
        style: TextStyle(color: AppColors.active, fontSize: 15),
      ),
    );
  }

  /// 歌手封面
  Widget _singImg() {
    return AspectRatio(
      aspectRatio: 1 / 1,
      child: ClipRRect(
        borderRadius: BorderRadius.circular(10),
        child: FadeInImage.assetNetwork(
          placeholder: 'assets/images/common/lazy-1.png',
          image: coverPictureUrl,
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}
